﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
   public partial class Form1 : Form
   {
      private WindowsFormsApplication1.ServiceReference1.Service1Client client;

      public Form1()
      {
         InitializeComponent();
         client = new ServiceReference1.Service1Client();
      }

      private void FillGrid()
      {
         int count = (int)numericUpDown1.Value;
         var list = client.GetPersonList(count);
         personBindingSource.DataSource = list;
      }

      private void Form1_Load(object sender, EventArgs e)
      {
         numericUpDown1.Value = 10;
         FillGrid();
      }

      private void button1_Click(object sender, EventArgs e)
      {
         FillGrid();
      }

      protected override void OnClosed(EventArgs e)
      {
         client.Close();
         base.OnClosed(e);
      }
   }
}
